package cn.doitedu.dynamic_rule.demos;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.sql.*;

/**
 * @author 袁海龙
 * @desc
 *   `id` int(11) NOT NULL AUTO_INCREMENT,
 *   `rule_name` varchar(255) DEFAULT NULL,
 *   `rule_code` varchar(4096) DEFAULT NULL,
 */
public class ReadDrlToMySqlDemo {
    public static void main(String[] args) throws IOException, SQLException {
        String ruleName = "rule2";
        String ruleCode = FileUtils.readFileToString(new File("D:\\work\\git\\flink_marketing_clickhouse_drools\\dynamic_rule_engine\\src\\main\\resources\\rules\\flink.drl"), "utf-8");
        Connection conn = DriverManager.getConnection("jdbc:mysql://192.168.112.101:3306/flink_test", "root", "123456");
        PreparedStatement pst = conn.prepareStatement("insert into test_drools (rule_name,rule_code) values (?,?)");
        pst.setString(1,ruleName);
        pst.setString(2,ruleCode);
        boolean execute = pst.execute();

        pst.close();
        conn.close();


    }
}
